package com.plian.system.wrapper.qg.guarantee;

import com.plian.system.dto.qg.guarantee.PropertyGuaranteeApplyDTO;
import com.plian.system.entity.qg.guarantee.PropertyGuaranteeApply;
import com.plian.system.mybatis.support.BaseWrapper;
import com.plian.system.vo.qg.guarantee.PropertyGuaranteeApplyVO;
import com.plian.system.wrapper.util.CacheWrapperUtil;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import static com.plian.system.wrapper.util.WrapperConstant.*;

/**
 * @description:
 * @author: gangan
 * @create: 2022-01-10 18:36
 */
@Mapper(componentModel = SPRING, uses = {CacheWrapperUtil.class})
public interface PropertyGuaranteeApplyWrapper extends BaseWrapper<PropertyGuaranteeApply, PropertyGuaranteeApplyDTO, PropertyGuaranteeApplyVO> {

    /**
     * Entity转VO
     *
     * @param entity /
     * @return /
     */
    @Override
    @Mappings(value = {
            @Mapping(source = "applyNameId", target = "applyName", qualifiedByName = ORG_ID_TO_NAME),
            @Mapping(source = "guaranteeCompanyId", target = "guaranteeCompanyName", qualifiedByName = ORG_ID_TO_NAME),
            @Mapping(source = "createUser", target = "createUserName", qualifiedByName = USER_ID_TO_NAME),
            @Mapping(source = "updateUser", target = "updateUserName", qualifiedByName = USER_ID_TO_NAME),
            @Mapping(source = "approvedUser", target = "approvedUserName", qualifiedByName = USER_ID_TO_NAME),

            @Mapping(source = "unitRankId", target = "unitRankName", qualifiedByName = DICT_CODE_TO_NAME),
            @Mapping(source = "guaranteeModeId", target = "guaranteeModeName", qualifiedByName = DICT_CODE_TO_NAME),
            @Mapping(source = "guaranteeDutyId", target = "guaranteeDutyName", qualifiedByName = DICT_CODE_TO_NAME),
            @Mapping(source = "loanTypeId", target = "loanTypeName", qualifiedByName = DICT_CODE_LIST_TO_NAME),
            @Mapping(source = "loanNatureId", target = "loanNatureName", qualifiedByName = DICT_CODE_LIST_TO_NAME)
    })
    PropertyGuaranteeApplyVO entityToVO(PropertyGuaranteeApply entity);
}
